<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@include file="../../common/taglib.jsp" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
     <%@include file="../../common/common-css.jsp" %>
    <%@include file="../../common/common-js.jsp" %>
    <%@include file="../../common/init.jsp" %>
     <script type="text/javascript" src="${pageContext.servletContext.contextPath }/js/jquery-1.7.1.min.js"></script>
        <link href="${pageContext.servletContext.contextPath }/css/style.css" rel="stylesheet" type="text/css" />
    
    <script type="text/javascript">
    function checkpassword(){
    	var oldpassword = $("#oldpassword").val();
    	var newpassword = $("#newpassword").val();
    	var againpassword = $("#againpassword").val();
    	var id = $("#id").val();
    	if(newpassword.trim() == ''){
    		alert("新密码不能为空！");
    		return;
    	}
    	if(newpassword.trim() == againpassword.trim()){
	    	$.ajax({url:"${pageContext.servletContext.contextPath }/background/serviceProvider/checkpassword.html?id="+id+"&oldpassword="+oldpassword,
			   type:"post",
			   cache:"false",
			   error : function() {
				   alert("系统繁忙，请稍后再试！");
				},
			   success:function(msg){
				  if(msg == '0'){
					  $.ajax({url:"${pageContext.servletContext.contextPath }/background/serviceProvider/updatePasswordInfo.html?id="+id+"&newpassword="+newpassword,
						   type:"post",
						   cache:"false",
						   error : function() {
							   alert("系统繁忙，请稍后再试！");
							},
						   success:function(msg){
							   alert("密码修改成功，需要重新登录！");
							   top.location.href='${pageContext.servletContext.contextPath }/background/login.html';
						   }
						});
				  }else if(msg == '1'){
					  alert("原密码输入不正确！");
				  }
			   }
			});
    	}else{
    		alert("两次输入的密码不一致！");
    	}
    }
    
    </script>
  </head>
  
  <body>
<form action="${pageContext.servletContext.contextPath }/background/serviceProvider/checkpassword.html" id="form1" method="post" data-validator-option="{theme:'yellow_right_effect',stopOnError:true}">
		<input type="hidden" name="id" id="id" value="${serviceProvider.id}">
		<div class="right">
        	<div class="volume">
            	<img src="${pageContext.servletContext.contextPath }/images/toleft.png" style="margin:23px 0 0 2px;_margin:23px 0 0 0px;" />
            </div>
        	<div class="rightcon">
            	<div class="title">
                	您当前的位置：首页 >服务商管理 > 修改服务商密码
                </div>
                	<div class="titlecon">
                           	 修改服务商密码
                    </div>
                	<div class="addlist">
                        
                        	<table class="addlistcon" border="0" cellpadding="0" cellspacing="0">
                            	<tr>
                                	<td width="30%" align="right" class="odd"><span style="color:#900">*</span>原密码：
                                    </td>
                                    <td width="70%"  class="even">
                                   <input style="height: 20px;width: 200px" name="oldpassword" id="oldpassword" type="password" data-rule="原密码: required;name;"/>
                                    </td>
                                </tr>
                                <tr>
                                	<td  align="right" class="odd"><span style="color:#900">*</span>新密码：
                                    </td>
                                    <td   class="even"> 
                                    <input style="height: 20px;width: 200px" name="newpassword" id="newpassword" type="password" data-rule="新密码: required;name;"/>
                                    </td>
                                </tr>
                                <tr>
                                	<td  align="right" class="odd"><span style="color:#900">*</span>确认密码：
                                    </td>
                                    <td   class="even" id="typeId">
										<input style="height: 20px;width: 200px" name="againpassword" id="againpassword" type="password" data-rule="确认密码: required;name;"/>
                                    </td>
                                </tr>
                              </table> 
                              <div class="savere" style="float:center; margin-left:34%; _margin-left:17%;">
                                <a href="#" onclick="checkpassword();"><img src="${pageContext.servletContext.contextPath }/images/baocun.png" width="101" height="46"></a>
							        <a href="javascript:history.go(-1)" ><img src="${pageContext.servletContext.contextPath }/images/fanhui.png" width="101" height="46"></a>
                            </div>
                         
                    </div><!--addlist-->
            </div><!--rightcon-->
        </div><!--right-->
</form>
  </body>
</html>
